<!-- 搜索表单 -->
<template>
  <ele-card :body-style="{ paddingBottom: '2px' }">
    <el-form label-width="72px" @keyup.enter="search" inline>
      <el-form-item label="状态">
        <el-radio-group v-model="form.status" @change="search">
          <el-radio-button :label="99999999">不限</el-radio-button>
          <el-radio-button :label="0">待付款</el-radio-button>
          <el-radio-button :label="20">已付款</el-radio-button>
          <el-radio-button :label="90">已拒绝</el-radio-button>
        </el-radio-group>
      </el-form-item>
      <br />
      <el-form-item label="分类">
        <el-radio-group v-model="form.cate" @change="search">
          <el-radio-button label="不限">不限</el-radio-button>
          <el-radio-button
            :label="item.title"
            v-for="item in cateList"
            :key="item.id"
          >
            {{ item.title }}
          </el-radio-button>
        </el-radio-group>
      </el-form-item>
      <br />
      <el-form-item label="车队名称">
        <el-input v-model.trim="form.company" />
      </el-form-item>
      <el-form-item label="车牌号码">
        <el-input v-model.trim="form.plate_number" />
      </el-form-item>

      <el-form-item label-width="16px">
        <el-button type="primary" @click="search">查询</el-button>
      </el-form-item>
    </el-form>
  </ele-card>
</template>

<script setup>
  import { ref } from 'vue';

  import { useFormData } from '@/utils/use-form-data';
  import { pageVehicleIncomeExpenseCate } from '@/api/company';

  const emit = defineEmits(['search']);

  /** 表单数据 */
  const [form] = useFormData({
    status: 0,
    io_type: '支出',
    cate: '不限',
    company: '',
    area_id: 0,
    plate_number: ''
  });

  /** 分类 */
  const cateList = ref([]);

  pageVehicleIncomeExpenseCate({ limit: 99999999 })
    .then((res) => {
      cateList.value = res.list;
    })
    .catch((e) => {
      console.log(e);
    });

  /** 搜索 */
  const search = () => {
    console.log(form);
    emit('search', { ...form });
  };
</script>
